package com.kfm.servlet.day01;

import javax.servlet.*;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;

@WebServlet(urlPatterns = {"/s", "/servlet"}, loadOnStartup = 1
        , initParams = {
                @WebInitParam(name = "name", value = "kfm")
                , @WebInitParam(name = "age", value = "18")
        })
public class MyServlet implements Servlet {

    private ServletConfig servletConfig;

    public MyServlet() {
        System.out.println("MyServlet()");
    }
    @Override
    public void init(ServletConfig servletConfig) throws ServletException {
        System.out.println("init()");
        this.servletConfig = servletConfig;
    }

    @Override
    public ServletConfig getServletConfig() {
        return this.servletConfig;
    }

    @Override
    public void service(ServletRequest servletRequest, ServletResponse servletResponse) throws ServletException, IOException {
        System.out.println("service()");
    }

    @Override
    public String getServletInfo() {
        return "MyServlet";
    }

    @Override
    public void destroy() {
        System.out.println("destroy()");
    }
}
